const Sequelize = require("sequelize");
const config = require("../config/sqlConf");

var sequelize = new Sequelize(
  config.database,
  config.username,
  config.password,
  {
    host: config.host,
    dialect: "mysql", //驱动
    pool: {
      max: 5,
      min: 0,
      idle: 10000,
    },
  }
);

sequelize
  .authenticate()
  .then(() => {
    console.log("successfully");
  })
  .catch((err) => {
    console.error("failure", err);
  });

const studentModel = require("../models/t_student")(sequelize, Sequelize);
studentModel.sync();

studentModel.create({
  s_id: null,
  s_name: "柯南1",
  s_sex: "女",
  s_phone: "12435467",
  s_cid: "2",
  s_age: "23",
  s_grade: "34",
});
// var now = Date.now();
// sequelize.sync({ force: false }).then(() => {
//   Stu.create({
//     s_id: "300",
//     s_name: "Odie",
//     s_sex: "男",
//     s_date: now,
//     s_phone: "1353465702",
//     s_cid: 3,
//     s_age: "02",
//     s_grade: "99",
//   })
//     .then(() => {
//       return Stu.find({
//         where: {
//           s_name: "小王",
//         },
//       });
//     })
//     .then((res) => {
//       console.log(res);
//     });
//   console.log("created: " + JSON.stringify(dogStu));
// });
